[Tkinter/Python] Different line widths with canvas.create_line?

Posted by Sam on Stack Overflow See other posts from Stack Overflow or by Sam
Published on 2010-05-09T01:34:25Z Indexed on 2010/05/09 1:38 UTC
Read the original article Hit count: 242

Filed under:
|
|

Does anyone have any idea why I get different line widths on the canvas in the following example?

from Tkinter import *
bigBoxSize = 150

class cFrame(Frame):
    def __init__(self, master, cwidth=450, cheight=450):
        Frame.__init__(self, master, relief=RAISED, height=550, width=600, bg = "grey")
        self.canvasWidth = cwidth
        self.canvasHeight = cheight
        self.canvas = Canvas(self, bg="white", width=cwidth, height=cheight, border =0)
        self.drawGridLines()
        self.canvas.pack(side=TOP, pady=20, padx=20)

    def drawGridLines(self, linewidth = 10):
        self.canvas.create_line(0, 0, self.canvasWidth, 0, width= linewidth )
        self.canvas.create_line(0, 0, 0, self.canvasHeight, width= linewidth )

        self.canvas.create_line(0, self.canvasHeight, self.canvasWidth + 2, self.canvasHeight, width= linewidth )
        self.canvas.create_line(self.canvasWidth, self.canvasHeight, self.canvasWidth, 1, width= linewidth )

        self.canvas.create_line(0, bigBoxSize, self.canvasWidth, bigBoxSize, width= linewidth )
        self.canvas.create_line(0, bigBoxSize * 2, self.canvasWidth, bigBoxSize * 2, width= linewidth)


root = Tk()
C = cFrame(root)
C.pack()
root.mainloop()

It's really frustrating me as I have no idea what's happening. If anyone can help me out then that'd be fantastic. Thanks!

© Stack Overflow or respective owner

Related posts about python

Related posts about tkinter